<%@ page import="com.jiuyun.dao.ClassesDao" %>
<%@ page import="com.jiuyun.dao.impl.ClassesDaoImpl" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.HashMap" %>
<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
  <head>
    <title>Title</title>
    <%
      request.setAttribute("num",5);
      request.setAttribute("money",1234);
      request.setAttribute("week",3);

      String names[]={"提莫","小丑","亚索","德玛","德莱文"};
      request.setAttribute("heros",names);

        ClassesDao dao=new ClassesDaoImpl();
        List list= dao.getClasses();
        request.setAttribute("list",list);

        HashMap map=new HashMap();
        map.put(1,"1");
        map.put(2,"2");
        map.put(3,"3");
        request.setAttribute("map",map);
    %>
  </head>
  <body>
  <h1>jstl 测试</h1>
  <h3>数据=${num}</h3>
  <!--原样输出值  当值为空的时候default()  禁用escapeXml(false) -->
  <h3>数据=<c:out value="${num}" default="没找到" escapeXml="false"></c:out></h3>

  <h3>IF</h3>
  <c:if test="${money>5000}">
      你的工资${money}可以找老婆了
  </c:if>
  <c:if test="${money<5000}">
    还差${5000-money}就可以找老婆了
  </c:if>

  <!--when条件   otherwise未达成条件-->
  <h3>chose , when , otherwise</h3>
  <c:choose>
    <c:when test="${week==1}">
      我去看电影
    </c:when>
    <c:when test="${week==2}">
      我去排位
    </c:when>
    <c:otherwise>
      搞学习
    </c:otherwise>
  </c:choose>

  <h3>forEach</h3>
  <c:forEach begin="1" end="${week}" var="k" step="2">
    <a href="#">${k}--</a>
  </c:forEach>
  <c:forEach items="${heros}" var="obj" varStatus="i">
    <br>
    <c:if test="${i.count%2==0}">
      <a style="color: red">${i.count}</a>
    </c:if>
    <c:if test="${i.count%2!=0}">
      <a style="color: black">${i.count}</a>
    </c:if>
    ${obj}
  </c:forEach>

 <%-- 集合 + 对象 --%>
  <c:forEach items="${list}" var="ban">
      <br>${ban.classId} -- ${ban.className}
  </c:forEach>
  <c:forEach items="${map}" var="obj">
      <br>${obj.key} -- ${obj.value}
  </c:forEach>
  </body>
</html>
